package com.miyake.dsp.converter.ui;

import com.miyake.dsp.converter.OffsetSetting;
import com.miyake.dsp.ui.DspTextField;
import com.miyake.dsp.ui.DspWidget;
import com.miyake.dsp.ui.DspWidget.DspWidgetHandler;

public class OffsetSettingUI extends DspWidget {
	private OffsetSetting setting;

	
	public OffsetSettingUI(OffsetSetting setting) {
		super();
		this.setting = setting;
		initialize();
	}

	private void initialize() {
		createOffset();
	}

	private void createOffset() {
		DspTextField text = new DspTextField("Offset");
		text.setValue(String.valueOf(setting.getOffset()));
		this.add(text);
		
		text.addHandler(new DspWidgetHandler() {
			@Override
			public void onChange(String value) {
				setting.setOffset(Double.valueOf(value));
				fireChange(value);
			}
		});	
	}

	public OffsetSetting getSetting() {
		return setting;
	}

	public void setSetting(OffsetSetting setting) {
		this.setting = setting;
	}
	
	
}
